package com.ruoyi.web.controller.cems;

import com.ruoyi.cems.domain.BmsEvcAlternateAirport;
import com.ruoyi.cems.service.IBmsEvcAlternateAirportService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 备降机场联络信息;Controller
 * 
 * @author ruoyi
 * @date 2024-07-22
 */
@RestController
@RequestMapping("/cems/evcAlternateAirport")
public class BmsEvcAlternateAirportController extends BaseController
{
    @Autowired
    private IBmsEvcAlternateAirportService bmsEvcAlternateAirportService;

    /**
     * 查询备降机场联络信息;列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BmsEvcAlternateAirport bmsEvcAlternateAirport)
    {
        startPage();
        List<BmsEvcAlternateAirport> list = bmsEvcAlternateAirportService.selectBmsEvcAlternateAirportList(bmsEvcAlternateAirport);
        return getDataTable(list);
    }

    /**
     * 导出备降机场联络信息;列表
     */
    @Log(title = "备降机场联络信息;", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BmsEvcAlternateAirport bmsEvcAlternateAirport)
    {
        List<BmsEvcAlternateAirport> list = bmsEvcAlternateAirportService.selectBmsEvcAlternateAirportList(bmsEvcAlternateAirport);
        ExcelUtil<BmsEvcAlternateAirport> util = new ExcelUtil<BmsEvcAlternateAirport>(BmsEvcAlternateAirport.class);
        util.exportExcel(response, list, "备降机场联络信息;数据");
    }

    /**
     * 获取备降机场联络信息;详细信息
     */
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") String ID)
    {
        return success(bmsEvcAlternateAirportService.selectBmsEvcAlternateAirportByID(ID));
    }

    /**
     * 新增备降机场联络信息;
     */
    @Log(title = "备降机场联络信息;", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmsEvcAlternateAirport bmsEvcAlternateAirport)
    {
        return toAjax(bmsEvcAlternateAirportService.insertBmsEvcAlternateAirport(bmsEvcAlternateAirport));
    }

    /**
     * 修改备降机场联络信息;
     */
    @Log(title = "备降机场联络信息;", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmsEvcAlternateAirport bmsEvcAlternateAirport)
    {
        return toAjax(bmsEvcAlternateAirportService.updateBmsEvcAlternateAirport(bmsEvcAlternateAirport));
    }

    /**
     * 删除备降机场联络信息;
     */
    @Log(title = "备降机场联络信息;", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable String[] IDs)
    {
        return toAjax(bmsEvcAlternateAirportService.deleteBmsEvcAlternateAirportByIDs(IDs));
    }
}
